﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;

using AMPLibrary;
using AMPLibrary.Media;

namespace MediaLibrary
{
    public class PlaylistMediaDataTemplateSelector : DataTemplateSelector
    {
        public DataTemplate AudioTemplate
        {
            get
            {
                return App.Current.FindResource("nowPlayingAudioDataTemplate") as DataTemplate;
            }
        }

        public DataTemplate VideoTemplate
        {
            get
            {
                return App.Current.FindResource("nowPlayingVideoDataTemplate") as DataTemplate;
            }
        }

        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            DataTemplate dataTemplate = null;
            MediaFile media = (MediaFile)item;

            if (media == null)
                return null;

            if (media.MimeType == MimeTypes.MP3)
                dataTemplate = AudioTemplate;
            else if (media.MimeType == MimeTypes.AVI)
                dataTemplate = VideoTemplate;

            return dataTemplate;
        }
    }
}